package org.dromara.common.model.enums.groupuser;

/**
 * 群成员与群的关系状态
 * @author Stars
 */
public enum GroupMemberStatusEnum {
    INVITATION_SENT("InvitationSent", "发送邀请"),
    ACCEPTED("Accepted", "同意"),
    REJECTED("Rejected", "拒绝");

    private final String code;
    private final String description;

    GroupMemberStatusEnum(String code, String description) {
        this.code = code;
        this.description = description;
    }

    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    /**
     * 根据状态代码获取对应的状态描述
     * @param code 状态代码
     * @return 对应的状态描述，如果未找到则返回 null
     */
    public static String getDescriptionByCode(String code) {
        for (GroupMemberStatusEnum status : values()) {
            if (status.getCode().equals(code)) {
                return status.getDescription();
            }
        }
        return null;
    }
}
